//SPDX-FileCopyrightText: Copyright 2022-2024 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package mail_serv

import (
	"time"

	"atomgit.com/openlinksaas-org/api-server/config"
	"github.com/emersion/go-smtp"
)

func RunServer(clientCfg *config.ClientCfg, exitChan chan error) {
	s := smtp.NewServer(newMailBackEnd(clientCfg.MaxMailCountPerUser))
	s.Addr = "0.0.0.0:25"
	s.Domain = clientCfg.UserMailDomain
	s.WriteTimeout = 10 * time.Second
	s.ReadTimeout = 10 * time.Second
	s.MaxMessageBytes = 128 * 1024
	s.MaxRecipients = 50
	s.AllowInsecureAuth = true

	err := s.ListenAndServe()
	exitChan <- err
}
